﻿namespace BlackHole.DAO
{
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;

    public static partial class Utility
    {
        public static bool DistrictAddNew(string districtName)
        {
            int ret;
            using (SqlConnection conn = new SqlConnection(ConnStr))
            {
                SqlCommand cmd = new SqlCommand("DistrictAddNew", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@districtName", districtName);
                conn.Open();
                ret = cmd.ExecuteNonQuery();
                return
                    ret == 0 ? false : true;
            }
        }

        public static bool OwnerAddNew(int districtId, string ownerName)
        {
            int ret;
            using (SqlConnection conn = new SqlConnection(ConnStr))
            {
                SqlCommand cmd = new SqlCommand("OwnerAddNew", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@districtId", districtId);
                cmd.Parameters.AddWithValue("@ownerName", ownerName);
                conn.Open();
                ret = cmd.ExecuteNonQuery();
                return
                    ret == 0 ? false : true;
            }
        }

        public static bool DeviceAddNew(string deviceName)
        {
            int ret;
            using (SqlConnection conn = new SqlConnection(ConnStr))
            {
                SqlCommand cmd = new SqlCommand("DeviceAddNew", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@deviceName", deviceName);
                conn.Open();
                ret = cmd.ExecuteNonQuery();
                return
                    ret == 0 ? false : true;
            }
        }
    }
}